package com.gxar.file.server.base.common.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 上传渠道目标枚举
 *
 * @author linsy
 * @version 1.0
 * @created 2023/7/12 21:00
 */
@Getter
public enum TargetChannelEnum {

    OSS(0, "oss", "阿里云OSS"),
    NAS(1, "nas", "Synology NAS"),
    MIN_IO(2, "MinIO", "MinIO"),
    ;

    private final Integer code;
    private final String name;
    private final String desc;

    TargetChannelEnum(Integer code, String name, String desc) {
        this.code = code;
        this.name = name;
        this.desc = desc;
    }

    public static TargetChannelEnum getChannelTargetByName(String name) {
        TargetChannelEnum targetChannelEnum = Arrays.stream(TargetChannelEnum.values()).filter(e -> e.getName().equals(name)).findFirst().orElse(null);
        if (Objects.nonNull(targetChannelEnum)) {
            return targetChannelEnum;
        }
        return null;
    }

}
